module("Module.ClubModule", package.seeall)

local NetMgr = require("NetWork").NetMgr
local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
ClubModule = {}

--------------------------------新协议
---请求当前玩家所有加入的俱乐部牌桌信息

function ClubModule.LoadUserTableCm(tableType,playType) --tableType 0 普通  1 比赛桌
	Debug.LogErrorEx("请求玩家所有牌桌信息"..stringify(tableType))
	local Msg = require("Protol.groupMessage_pb").LoadUserTableCm()
	if tableType then
		Msg.type = tableType
	end
	if playType ~= nil then
		Msg.playType = playType
	end
	--Msg.pageSize = 7
	NetMgr:SendMsg(2028, Msg)
end

function ClubModule.LoadUserTableSm(LoadUserTableSm)
	Debug.log("-------LoadUserTableSm.type--------"..LoadUserTableSm.type)
	
	--local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	local NewClubTablesWin = UIWinMgr:OpenWindow("NewClubTablesWin",1)
	NewClubTablesWin:BringToTop()
	if LoadUserTableSm.type == 0 then
		
		NewClubTablesWin:RoomSetData(LoadUserTableSm)
	else
		--NewClubTablesWin:MatchRoomSetData(LoadUserTableSm)
	end
end
-------------------------------------------------------------------------------------------------------------
-----请求所有俱乐部信息
function ClubModule.LoadGroupCm(location)
	Debug.LogErrorEx("请求俱乐部信息"..stringify(location))
	local Msg = require("Protol.groupMessage_pb").LoadGroupCm()
	if location then
		Msg.location = location
	end
	NetMgr:SendMsg(2009, Msg)
end

function ClubModule.LoadGroupSm(LoadGroupSm)
	Debug.LogErrorEx("收到LoadGroupSm-----------------------------"..stringify(LoadGroupSm))

	if LoadGroupSm.location == 0 then
		local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
		NewGameLoobyWin:ShowCLubList(LoadGroupSm)
	else
		local NewGamemyzhanghuWin = UIWinMgr:GetWindow("NewGamemyzhanghuWin")
		NewGamemyzhanghuWin:SetZhanghuInfo(LoadGroupSm)
	end
end

function ClubModule.CreateGroupCm(clubname,clublevel)
	Debug.LogErrorEx("请求创建俱乐部")
	local Msg = require("Protol.groupMessage_pb").CreateGroupCm()
	Msg.name = clubname
	Msg.level = clublevel
	NetMgr:SendMsg(2001, Msg)
	--UIWinMgr:OpenMask("创建俱乐部中...")
end

function ClubModule.CreateGroupSm(CreateGroupSm)
	Debug.LogErrorEx("收到CreateGroupSm-----------------------------"..stringify(CreateGroupSm))
	if CreateGroupSm.code == 0 then
		local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
   		--UIWinMgr:OpenNewGameNotice("创建俱乐部成功")

   		UIWinMgr:CloseWindow("NewGameCreateClubWin")
   		local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
   		NewGameLoobyWin.ChoseItemclub.value = true
   		local ClubModule = require("Module.ClubModule").ClubModule
		ClubModule.LoadGroupCm(0)
		--ClubModule.LoadGroupInfoCm(CreateGroupSm.id)
		local str = UIWinMgr:GetIntTextByCode(20)
		UIWinMgr:OpenNewGameNotice(str)
	end
end

function ClubModule.InviteJoinGroupCm(groupKey,userId)
	local Msg = require("Protol.groupMessage_pb").InviteJoinGroupCm()
	Msg.groupKey = tonumber(groupKey)
	Msg.userId = tonumber(userId) 
	NetMgr:SendMsg(2026, Msg)
end

function ClubModule.InviteJoinGroupSm(InviteJoinGroupSm)
	local str = UIWinMgr:GetIntTextByCode(21)
	UIWinMgr:OpenNotice(str)
	UIWinMgr:CloseWindow("NewInvitePlayerWin")
	local NewGameMyHuiYuanlistWin = UIWinMgr:GetWindow("NewGameMyHuiYuanlistWin")
	NewGameMyHuiYuanlistWin:UpdateCurMembers()
end

function ClubModule.JoinGroupCm(clubid)
	Debug.LogErrorEx("请求加入俱乐部")
	local Msg = require("Protol.groupMessage_pb").JoinGroupCm()
	Msg.id = clubid
	NetMgr:SendMsg(2002, Msg)
end

function ClubModule.JoinGroupSm(JoinGroupSm)
	Debug.LogErrorEx("--------收到加入俱乐部回包--------")
	local str = UIWinMgr:GetIntTextByCode(22)
	UIWinMgr:OpenNewGameNotice(str)
end

function ClubModule.LoadGroupJieSuanCm(groupKey,pageNo,pageSize)
	Debug.LogErrorEx("------------请求个人战局回顾消息--------------")
	Debug.log("------------请求个人战局回顾消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadGroupJieSuanCm()
	--------------先测试----------------
	if groupKey then
		Msg.groupKey = tonumber(groupKey)
	else
		Msg.groupKey = 0
	end
	if pageNo then
		Msg.pageNo = tonumber(pageNo)
	end
	if pageSize then
		Msg.pageSize = tonumber(pageSize)
	end
	NetMgr:SendMsg(2016, Msg)
end

function ClubModule.LoadGroupJieSuanSm(SearchGroupReviewSm)
	Debug.LogErrorEx("收到个人战局回顾回包-----------------------------"..stringify(SearchGroupReviewSm))
	Debug.log("收到个人战局回顾回包-----------------------------")
	-- local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	-- NewGameLoobyWin:MessageLeftSetData(SearchGroupReviewSm)
	local NewGameZhangJuHuiGuWin = UIWinMgr:GetWindow("NewGameZhangJuHuiGuWin")
	NewGameZhangJuHuiGuWin:ZhanjuSetData(SearchGroupReviewSm)
end

function ClubModule.LoadJieSuanTableCm(tableNo)
	Debug.LogErrorEx("请求个人战局回顾详情-----------------------------"..tableNo)
	local Msg = require("Protol.groupMessage_pb").LoadJieSuanTableCm()
	Msg.tableNo = tableNo
	NetMgr:SendMsg(2017, Msg)
end

function ClubModule.LoadJieSuanTableSm(LoadJieSuanTableSm)
	Debug.LogErrorEx("收到个人战局回顾详情回包-----------------------------"..stringify(LoadJieSuanTableSm))
	
	local NewGameZhanJuHuiGuXiangQingWin = UIWinMgr:GetWindow("NewGameZhanJuHuiGuXiangQingWin")
	NewGameZhanJuHuiGuXiangQingWin:ZhanjuSetData(LoadJieSuanTableSm)
end

function ClubModule.LoadGroupJieSuanTableCm(groupKey,allianceKey,pageNo,pageSize)
	Debug.LogErrorEx("------------请求俱乐部战局回顾消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadGroupJieSuanTableCm()
	--------------先测试----------------
	Msg.groupKey = tonumber(groupKey)
	Msg.allianceKey = tonumber(allianceKey)
	if pageNo then
		Msg.pageNo = tonumber(pageNo)
	end
	if pageSize then
		Msg.pageSize = tonumber(pageSize)
	else
		Msg.pageSize = 10
	end
	NetMgr:SendMsg(2020, Msg)
end

function ClubModule.LoadGroupJieSuanTableSm(LoadGroupJieSuanTableSm)
	Debug.log("收到俱乐部战局回顾回包-----------------------------"..stringify(LoadGroupJieSuanTableSm))
	-- local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	-- NewGameLoobyWin:MessageLeftSetData(SearchGroupReviewSm)
	local NewGameClubZhangJuHuiGuWin = UIWinMgr:GetWindow("NewGameClubZhangJuHuiGuWin")
	NewGameClubZhangJuHuiGuWin:ZhanjuSetData(LoadGroupJieSuanTableSm)
end

function ClubModule.LoadGroupJieSuanTableInfoCm(tableNo,groupKey)
	Debug.LogErrorEx("请求俱乐部战局回顾详情-----------------------------"..tableNo)
	local Msg = require("Protol.groupMessage_pb").LoadGroupJieSuanTableInfoCm()
	Msg.tableNo = tonumber(tableNo)
	Msg.groupKey = tonumber(groupKey)
	
	NetMgr:SendMsg(2021, Msg)
end

function ClubModule.LoadGroupJieSuanTableInfoSm(LoadGroupJieSuanTableInfoSm)
	Debug.LogErrorEx("收到俱乐部战局回顾详情回包-----------------------------"..stringify(LoadGroupJieSuanTableInfoSm))
	
	local NewGameClubZhanJuHuiGuXiangQingWin = UIWinMgr:GetWindow("NewGameClubZhanJuHuiGuXiangQingWin")
	NewGameClubZhanJuHuiGuXiangQingWin:ZhanjuSetData(LoadGroupJieSuanTableInfoSm)
end

function ClubModule.ActivityRecordReq(pageNo)
	local Msg = require("Protol.activityMessage_pb").ActivityRecordReq()
	Msg.pageNo = tonumber(pageNo)
	Msg.pageSize = 10

	NetMgr:SendMsg(2203, Msg)
end

function ClubModule.ActivityRecordRes(ActivityRecordRes)
	local NewChouJiangWin = UIWinMgr:OpenWindow("NewChouJiangWin")
	NewChouJiangWin:MessageSetData(ActivityRecordRes)
end

function ClubModule.SearchGroupReviewCm(reviewMode,groupId,pageNo,pageSize)
	Debug.LogErrorEx("------------请求消息--------------")
	local Msg = require("Protol.groupMessage_pb").SearchGroupMsgCm()
	if reviewMode then
		Msg.reviewMode = tonumber(reviewMode)
	end
	if groupId then
		Msg.groupId = tonumber(groupId)
	end

	if pageNo then
		Msg.pageNo = tonumber(pageNo)
	end
	if pageSize then
		Msg.pageSize = pageSize
	else
		Msg.pageSize = 10
	end
	
	NetMgr:SendMsg(2007, Msg)
end

function ClubModule.SearchGroupMsgSm(SearchGroupMsgSm)
	Debug.LogErrorEx("收到消息回包-----------------------------"..stringify(SearchGroupMsgSm))
	local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	NewGameLoobyWin:MessageSetData(SearchGroupMsgSm)
	-- if SearchGroupReviewSm.reviewMode == 0 then
	-- 	local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	-- 	NewGameLoobyWin:MessageSetData(SearchGroupReviewSm)
	-- else
	-- 	local GoldMsgWin = UIWinMgr:GetWindow("GoldMsgWin")
	-- 	GoldMsgWin:MessageSetData(SearchGroupReviewSm)
	-- end
end


----钻石消息
function ClubModule.RewardCdkCm(pageNo,pageSize)
	local Msg = require("Protol.commonMessage_pb").RewardCdkCm()

	if pageNo then
		Msg.pageNo = tonumber(pageNo)
	end
	if pageSize then
		Msg.pageSize = tonumber(pageSize) 
	else
		Msg.pageSize = 10
	end
	
	NetMgr:SendMsg(2106, Msg) --2108
end

----钻石消息返回
function ClubModule.RewardCdkSm(RewardCdkSm )

	local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	NewGameLoobyWin:DiaMessageSetData(RewardCdkSm)
end

------查看明细
function ClubModule.LoadGoldRecordCm(groupKey,pageNo,pageSize)
	Debug.LogErrorEx("------------请求消息---查看明细-----------")
	local Msg = require("Protol.groupMessage_pb").LoadGoldRecordCm()
	Msg.groupKey = tonumber(groupKey)

	if pageNo then
		Msg.pageNo = tonumber(pageNo)
	end

	if pageSize then
		Msg.pageSize = tonumber(pageSize)
	else
		Msg.pageSize = 10
	end

	NetMgr:SendMsg(2024, Msg)
end

function ClubModule.LoadGoldRecordSm(LoadGoldRecordSm)
	local GoldMsgWin = UIWinMgr:GetWindow("GoldMsgWin")
	GoldMsgWin:MessageSetData(LoadGoldRecordSm)
end

--查看积分详情记录
function ClubModule.LoadTableJpCm(userKey,pageNo,pageSize)
	local Msg = require("Protol.groupMessage_pb").LoadTableJpCm()
	Msg.userKey = tonumber(userKey)

	if pageNo then
		Msg.pageNo = tonumber(pageNo)
	end

	if pageSize then
		Msg.pageSize = tonumber(pageSize)
	end

	NetMgr:SendMsg(2025, Msg)
end

function ClubModule.LoadTableJpSm(LoadTableJpSm)

	local NewClubShouYiWin = UIWinMgr:GetWindow("NewClubShouYiWin")
	NewClubShouYiWin:HuiyuanSetData(LoadTableJpSm)
	
end

function ClubModule.ResponseGroupReviewCm(keyId,msgType,isok)
	Debug.LogErrorEx("------------是否同意加入联盟俱乐部消息--------------")
	local Msg = require("Protol.groupMessage_pb").ResponseGroupReviewCm()
	Msg.keyId = keyId
	--Msg.msgType = msgType
	Msg.val = isok
	NetMgr:SendMsg(2008, Msg)
end

function ClubModule.ResponseGroupReviewSm(ResponseGroupReviewSm)
	Debug.LogErrorEx("收到是否同意-----------------------------"..stringify(SearchGroupReviewSm))
	local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	NewGameLoobyWin:ResponseApplyAction()
end

-----创建联盟
function ClubModule.CreateAllianceCm(name,groupId)
	Debug.LogErrorEx("------------请求创建联盟消息--------------")
	local Msg = require("Protol.groupMessage_pb").CreateAllianceCm()
	Msg.name = name
	Msg.groupId = tonumber(groupId)
	NetMgr:SendMsg(2010, Msg)
end

function ClubModule.CreateAllianceSm(CreateAllianceSm)
	Debug.LogErrorEx("------------创建联盟消息--------------"..stringify(CreateAllianceSm))
	if CreateAllianceSm.code == 0 then
		local str = UIWinMgr:GetIntTextByCode(23)
		UIWinMgr:OpenNewGameNotice(str)
		local NewClubDetailsWin = UIWinMgr:OpenWindow("NewClubDetailsWin")
		NewClubDetailsWin:UpdateCurLianmengInfo(CreateAllianceSm.keyId)
		--ClubModule.LoadGroupInfoCm(CreateAllianceSm.groupKey)
	else
		local str = UIWinMgr:GetIntTextByCode(24)
		UIWinMgr:OpenNewGameNotice(str)
	end
end

-----加入联盟
function ClubModule.JoinAllianceCm(id,groupId)
	Debug.LogErrorEx("------------请求加入联盟消息--------------")
	local Msg = require("Protol.groupMessage_pb").JoinAllianceCm()
	Msg.id = id
	Msg.groupId = tonumber(groupId) 
	NetMgr:SendMsg(2011, Msg)
end

function ClubModule.JoinAllianceSm(JoinAllianceSm)
	Debug.LogErrorEx("------------加入联盟消息--------------"..stringify(JoinAllianceSm))
	if JoinAllianceSm.code == 0 then
		local str = UIWinMgr:GetIntTextByCode(25)
		UIWinMgr:OpenNewGameNotice(str)
	else
		local str = UIWinMgr:GetIntTextByCode(26)
		UIWinMgr:OpenNewGameNotice(str)
	end
end

-----请求联盟
function ClubModule.LoadAllianceInfoCm(keyId,groupId)
	Debug.LogErrorEx("------------请求联盟消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadAllianceInfoCm()
	Msg.keyId = keyId
	Msg.groupId = groupId
	NetMgr:SendMsg(2014, Msg)
end



function ClubModule.LoadAllianceInfoSm(LoadAllianceInfoSm)
	Debug.LogErrorEx("------------联盟消息--------------"..stringify(LoadAllianceInfoSm))
	local NewGameLianMengWin = UIWinMgr:GetWindow("NewGameLianMengWin")
	NewGameLianMengWin:SetMyLianmengInfo(LoadAllianceInfoSm)
end

function ClubModule.LoadAllianceGroupCm(groupKey,pageNo,searchGroupId,pageSize)
	Debug.LogErrorEx("------------查询联盟俱乐部列表--------------"..groupKey)
	local Msg = require("Protol.groupMessage_pb").LoadAllianceGroupCm()
	Msg.groupKey = tonumber(groupKey)
	if pageNo then
		Msg.pageNo = pageNo
	end
	if searchGroupId then 
		Msg.searchGroupId = tonumber(searchGroupId) 
	end
	if pageSize then
		Msg.pageSize = pageSize
	else
		pageSize = 10
	end
	NetMgr:SendMsg(2012, Msg)
end

function ClubModule.LoadAllianceGroupSm(LoadAllianceGroupSm)
	Debug.LogErrorEx("------------联盟俱乐部列表--------------"..stringify(LoadAllianceGroupSm))
	local NewGameLianMengWin = UIWinMgr:GetWindow("NewGameLianMengWin")
	NewGameLianMengWin:HuiyuanSetData(LoadAllianceGroupSm)
	--NewGameLianMengWin:BringToTop()
end

function ClubModule.LoadGroupSerchUsersCm(groupId,SerchStr,actionType)
	Debug.LogErrorEx("------------请求俱乐部默认玩家列表消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadGroupUsersCm()
	Msg.groupId = groupId
	Msg.keyWord = SerchStr
	if actionType then
		Msg.type = actionType
	end
	NetMgr:SendMsg(2003, Msg)
end

function ClubModule.LoadGroupUsersCm(groupId,actionType,pageNo,pageSize)
	Debug.LogErrorEx("------------请求俱乐部默认玩家列表消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadGroupUsersCm()
	Msg.groupId = tonumber(groupId) 
	if actionType then
		Msg.type = actionType
	end
	if pageNo then
		Msg.pageNo = pageNo 
	end
	if pageSize then
		Msg.pageSize = pageSize
	else
		pageSize = 10
	end
	
	NetMgr:SendMsg(2003, Msg)
end

function ClubModule.LoadGroupUsersJutiCm(groupId,pageNo,pageSize,actionType)
	Debug.LogErrorEx("------------请求俱乐部具体页数玩家列表消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadGroupUsersCm()
	if groupId then
		Msg.groupId = tonumber(groupId) 
	end
	Msg.pageNo = pageNo
	if pageSize then
		Msg.pageSize = pageSize
	end
	if actionType then
		Msg.type = actionType
	end
	NetMgr:SendMsg(2003, Msg)
end

function ClubModule.LoadGroupUsersChazhaoCm(groupId,pageNo,pageSize,keyWord)
	Debug.LogErrorEx("------------请求查找俱乐部具体页数玩家列表消息--------------")
	local Msg = require("Protol.groupMessage_pb").LoadGroupUsersCm()
	Msg.groupId = groupId
	Msg.pageNo = pageNo
	Msg.pageSize = pageSize
	Msg.keyWord = keyWord
	NetMgr:SendMsg(2003, Msg)
end

function ClubModule.LoadGroupUsersSm(LoadGroupUsersSm)
	Debug.LogErrorEx("------------收到俱乐部玩家列表消息--------------"..stringify(LoadGroupUsersSm))
	local NewGamehuiyuanlistWin = UIWinMgr:GetWindow("NewGamehuiyuanlistWin")
	NewGamehuiyuanlistWin:HuiyuanSetData(LoadGroupUsersSm)
	
	-- if LoadGroupUsersSm.type == 0 then
	-- 	local NewGamehuiyuanlistWin = UIWinMgr:GetWindow("NewGamehuiyuanlistWin")
	-- 	NewGamehuiyuanlistWin:HuiyuanSetData(LoadGroupUsersSm)
	-- elseif LoadGroupUsersSm.type == 1 or LoadGroupUsersSm.type == 2 then
	-- 	local NewGameMyHuiYuanlistWin = UIWinMgr:GetWindow("NewGameMyHuiYuanlistWin")
	-- 	NewGameMyHuiYuanlistWin:HuiyuanSetData(LoadGroupUsersSm)
	-- end
	
end

--获取收益积分及提升代理请求
--actionType 2 获取收益积分  3 提升代理设置比例 4 修改比例 5 回收金币
function ClubModule.GetShouyijifenCm(groupid,userId,shouyifen,actionType,uGroupKey)
	local Msg = require("Protol.groupMessage_pb").UpdateGroupUserCm()
	Msg.id = tonumber(groupid)
	Msg.userId = tonumber(userId)
	Msg.gold = tonumber(shouyifen) 
	Msg.type = tonumber(actionType)
	if uGroupKey then
		Msg.uGroupKey = tonumber(uGroupKey) 
	end
	NetMgr:SendMsg(2006, Msg)
end


------赠送金币
function ClubModule.UpdateGroupUserCm(groupid,userId,gold,ps,isToBoss,uGroupkey)

	if gold == nil or gold == nil then
		local str = UIWinMgr:GetIntTextByCode(27)
		UIWinMgr:OpenNewGameNotice(str)
		return
	end

	-- if ps == nil then
	-- 	UIWinMgr:OpenNewGameNotice("密码不符合")
	-- 	return
	-- end

	local Msg = require("Protol.groupMessage_pb").UpdateGroupUserCm()
	Debug.LogErrorEx("------------groupidgroupid--------------"..groupid)
	Debug.LogErrorEx("------------groupidgroupid--------------"..userId)
	Debug.LogErrorEx("------------groupidgroupid--------------"..gold)
	-- Debug.LogErrorEx("------------groupidgroupid--------------"..ps)
	Msg.id = groupid
	Msg.userId = userId
	Msg.gold = gold
	Msg.ps = "111111"
	if isToBoss then 
		Msg.type = isToBoss
	end
	if uGroupkey then
		Msg.uGroupKey = tonumber(uGroupkey) 
	end
	NetMgr:SendMsg(2006, Msg)
end

function ClubModule.FireGroupCm( id,useid )
	Debug.LogErrorEx("------------踢出俱乐部--------------"..id)
	local Msg = require("Protol.groupMessage_pb").FireGroupCm()
	Msg.id = id
	Msg.userId = useid
	NetMgr:SendMsg(2005, Msg)
end

function ClubModule.FireGroupSm( FireGroupSm )
	Debug.LogErrorEx("------------踢出俱乐部回包--------------"..stringify(FireGroupSm))
	if FireGroupSm.code == 0 then

		local ClubModule = require("Module.ClubModule").ClubModule
  		ClubModule.LoadGroupUsersCm(FireGroupSm.id)
		local str = UIWinMgr:GetIntTextByCode(28)
		UIWinMgr:OpenNewGameNotice(str)
	end
end

function ClubModule.UpdateOrDownGroupUserCm(groupid,userId,userole)
	local Msg = require("Protol.groupMessage_pb").UpdateGroupUserCm()
	Msg.id = groupid
	Msg.userId = userId
	Msg.userRole = userole
	NetMgr:SendMsg(2006, Msg)
end

function ClubModule.UpdateGroupUserSm(UpdateGroupUserSm)
	Debug.log("------------收到UpdateGroupUserSm消息--------------"..stringify(UpdateGroupUserSm))
	
	if UpdateGroupUserSm.type == 2 then
		local NewClubShouYiWin = UIWinMgr:GetWindow("NewClubShouYiWin")
		NewClubShouYiWin:UpdateSYJF(UpdateGroupUserSm.gold)
		local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
		NewClubDetailsWin:UpdateShouyi(UpdateGroupUserSm.gold)
		UIWinMgr:CloseWindow("NewTiQuShouYiWin")
	elseif UpdateGroupUserSm.type == 3 then 
			UIWinMgr:CloseWindow("NewClubProveWin")
			local NewGamehuiyuanlistWin = UIWinMgr:GetWindow("NewGamehuiyuanlistWin")
			NewGamehuiyuanlistWin:UpdateCurMembers()
	elseif UpdateGroupUserSm.type == 4 then 
		UIWinMgr:CloseWindow("NewPercentFixWin")
		if UpdateGroupUserSm.mark == 1 then
			ClubModule.LoadAllianceGroupCm(UpdateGroupUserSm.id,1)
		else
			local NewGamehuiyuanlistWin = UIWinMgr:GetWindow("NewGamehuiyuanlistWin")
			NewGamehuiyuanlistWin:UpdateCurMembers()
		end

	elseif UpdateGroupUserSm.type == 1 then 
		local MainUserData = require("DynamicData.MainUserData").MainUserData
		MainUserData.currentclubgold = UpdateGroupUserSm.gold
		if UpdateGroupUserSm.mark == 1 then
			ClubModule.LoadAllianceGroupCm(UpdateGroupUserSm.id,1)
			local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
			NewClubDetailsWin:UpdateMyCoin(UpdateGroupUserSm.gold)
		else
			local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
			NewClubDetailsWin:UpdateMyCoin(UpdateGroupUserSm.gold)
		end
		--local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
		--NewGameLoobyWin:UpdateMyCoin(UpdateGroupUserSm.gold)

		
		
	elseif UpdateGroupUserSm.type == 5 then 
		local MainUserData = require("DynamicData.MainUserData").MainUserData
		MainUserData.currentclubgold = UpdateGroupUserSm.gold
		local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
		NewClubDetailsWin:UpdateMyCoin(UpdateGroupUserSm.gold)
		local NewGamehuiyuanlistWin = UIWinMgr:GetWindow("NewGamehuiyuanlistWin")
		NewGamehuiyuanlistWin:UpdateCurMembers()

	else
	-- 	local ClubModule = require("Module.ClubModule").ClubModule
  	-- ClubModule.LoadGroupUsersCm(UpdateGroupUserSm.id)

	-- 	if UpdateGroupUserSm.code == 0 then
	-- 		Event.Brocast(EventDefine.OnGoldChange, UpdateGroupUserSm.gold)
	-- 	end
		local NewGamehuiyuanlistWin = UIWinMgr:GetWindow("NewGamehuiyuanlistWin")
		NewGamehuiyuanlistWin:UpdateCurMembers()
		local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
		NewClubDetailsWin:UpdateMyCoin(UpdateGroupUserSm.gold)
	end
	UIWinMgr:OpenNewGameNotice(UpdateGroupUserSm.msg)
end

-------获取牌桌列表,这里临时保存下联盟id
function ClubModule.LoadGroupTableCm(groupKey,allianceKey,mark,pageNo,playType)
	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.allianceKey = allianceKey
	ClubModule.groupKey = groupKey
	local Msg = require("Protol.groupMessage_pb").LoadGroupTableCm()
	Msg.groupKey = tonumber(groupKey)
	Msg.allianceKey = tonumber(allianceKey)
	Msg.mark = mark
	if pageNo then
		Msg.pageNo = pageNo
	end
	if playType then
		Msg.type = playType
	else
		Msg.type = 0
	end
	--Msg.pageSize =100
	Debug.LogErrorEx("------------发送LoadGroupTableCm消息--------------"..stringify(Msg))
	NetMgr:SendMsg(2015, Msg)
end

function ClubModule.LoadGroupTableSm(LoadGroupTableSm)

	if LoadGroupTableSm.mark == 0 then
		local NewClubTablesWin = UIWinMgr:OpenWindow("NewClubTablesWin",1)
		NewClubTablesWin:RoomSetData(LoadGroupTableSm)
		NewClubTablesWin:BringToTop()
	elseif LoadGroupTableSm.mark == 1 then
		local NewClubTablesWin = UIWinMgr:GetWindow("NewClubTablesWin",1)
		NewClubTablesWin:RoomSetData(LoadGroupTableSm)
	end
	Debug.LogErrorEx("------------收到LoadGroupTableSm消息--------------"..stringify(LoadGroupTableSm))

	-- if LoadGroupTableSm.mark == 1 then
	-- 	local NewGamepaijulistWin = UIWinMgr:OpenWindow("NewGamepaijulistWin")
	-- 	NewGamepaijulistWin:SetRoomsInfo(LoadGroupTableSm)
	-- 	NewGamepaijulistWin:BringToTop()
	-- else
	-- 	local NewGamepaijulistWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	-- 	NewGamepaijulistWin:RoomSetData(LoadGroupTableSm)
	-- end
end


-------创建房间通用消息
function ClubModule.CreateRoomCm(groupkey,time,choushui,minidairu,difen,roomname)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建牛牛开船房间----------------"..stringify(roomname))
		table.insert(Msg.params,time)	---游戏总时间
		table.insert(Msg.params,1)	---玩法ID
		table.insert(Msg.params,10)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		table.insert(Msg.params,difen)	---低分

		table.insert(Msg.strParams,tostring(groupkey))	---游戏总时间
		table.insert(Msg.strParams,roomname)	---房间名字
		
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(1,0,callback)
end


-------创建盲压房间通用消息
function ClubModule.CreateRoomMYCm(groupkey,time,choushui,minidairu,qiangzhuangfei,roomname)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建闲家推注房间----------------"..stringify(roomname))
		table.insert(Msg.params,time)	---游戏总时间
		table.insert(Msg.params,3)	---玩法ID
		table.insert(Msg.params,8)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		table.insert(Msg.params,qiangzhuangfei)	---最小抢庄

		table.insert(Msg.strParams,tostring(groupkey))	---游戏总时间
		table.insert(Msg.strParams,roomname)	---房间名字
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(3,0,callback)
end

--------创建推筒子房间通用消息
function ClubModule.CreateRoomTTZCm(groupKey,time,choushui,minidairu,roomname)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建推筒子房间---------------"..stringify(roomname))
		table.insert(Msg.params,time) ------游戏时间
		table.insert(Msg.params,4) --------玩法ID
		table.insert(Msg.params,7) --------最大座位
		table.insert(Msg.params,2) --------支付方式
		table.insert(Msg.params,minidairu) ---最小带入
		table.insert(Msg.params,choushui) ---抽水 0-5

		table.insert(Msg.strParams,tostring(groupKey)) ---游戏总时间
		table.insert(Msg.strParams,roomname) ---房间名字
		NetMgr:SendMsg(1002,Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(4,0,callback)
end

--创建高倍牛牛房间通用消息
function ClubModule.CreateRoomGBNNCm(groupkey,totalTime,playPeople,choushui,minChoushuiPoint,autoBeginRoom,minidairu,roomname)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建闲家推注房间----------------"..stringify(roomname))
		table.insert(Msg.params,totalTime)	---游戏总时间
		table.insert(Msg.params,5)	---玩法ID
		table.insert(Msg.params,playPeople)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		table.insert(Msg.params,minChoushuiPoint)	---抽水起点 0 ，10
		table.insert(Msg.params,autoBeginRoom)	--- 

		table.insert(Msg.strParams,tostring(groupkey))	---游戏总时间
		table.insert(Msg.strParams,roomname)	---房间名字
		
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(5,0,callback)
end

--创建炸金花房间通用消息
function ClubModule.CreateRoomZJHCm(groupkey,totalTime,playPeople,choushui,turnMax,bimenQuanshu,isXi,isFangHuopai,minidairu,roomname,beichang,notLookButBet,tableType)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建炸金花房间----------------"..stringify(roomname))
		table.insert(Msg.params,totalTime)	---游戏总时间
		table.insert(Msg.params,6)	---玩法ID
		table.insert(Msg.params,playPeople)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		table.insert(Msg.params,turnMax)	---最大轮数
		table.insert(Msg.params,bimenQuanshu)	---必闷圈数 
		table.insert(Msg.params,isXi)	--- 是否有喜钱
		table.insert(Msg.params,isFangHuopai)	---防伙牌
		table.insert(Msg.params,beichang)	---倍场 1是短牌 0是普通场 2是丰富场
		table.insert(Msg.params,notLookButBet)	--暗牌是否可以下注

		

		table.insert(Msg.strParams,tostring(groupkey))	---俱乐部ID
		table.insert(Msg.strParams,roomname)	---房间名字
		if tableType ~= nil then
			table.insert(Msg.strParams,tostring(tableType))	---游戏类型 0普通 1 比赛场
		else
			table.insert(Msg.strParams,"0")	---游戏类型 0普通 1 比赛场
		end
		
		
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(6,0,callback)
end

-------创建三公房间通用消息
function ClubModule.CreateSanGongRoomCm(groupkey,time,choushui,minidairu,difen,roomname)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建三公房间----------------"..stringify(roomname))
		table.insert(Msg.params,time)	---游戏总时间
		table.insert(Msg.params,7)	---玩法ID
		table.insert(Msg.params,10)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		table.insert(Msg.params,difen)	---低分

		table.insert(Msg.strParams,tostring(groupkey))	---游戏总时间
		table.insert(Msg.strParams,roomname)	---房间名字
		
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(7,0,callback)
end

-------创建博弈圈牛牛房间通用消息
function ClubModule.CreateRoomBYQNNCm(groupkey,maxround,maxPeople,choushui,minidairu,gaobei,laizi,roomname,tableType)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建闲家推注房间----------------"..stringify(roomname))
		table.insert(Msg.params,maxround)	---游戏总时间
		table.insert(Msg.params,8)	---玩法ID
		table.insert(Msg.params,maxPeople)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		
		
		
		table.insert(Msg.params,gaobei)	-----是否高倍  0不是高倍
		table.insert(Msg.params,laizi)	--是否癞子 0不是 1王 2 随

		table.insert(Msg.strParams,tostring(groupkey))	---游戏总时间
		table.insert(Msg.strParams,roomname)	---房间名字
		if tableType ~= nil then
			table.insert(Msg.strParams,tostring(tableType))	---游戏类型 0普通 1 比赛场
		else
			table.insert(Msg.strParams,"0")	---游戏类型 0普通 1 比赛场
		end
		
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(8,0,callback)
end

-------创建博弈圈牛牛房间通用消息
function ClubModule.CreateRoomDeZhouCm(groupkey,maxround,maxPeople,choushui,minidairu,roomname)
	function callback()
		local Msg = require("Protol.comMessage_pb").ComReq()
		Msg.code=1
		Debug.LogErrorEx("发送创建德州房间----------------"..stringify(roomname))
		table.insert(Msg.params,maxround)	---游戏总时间
		table.insert(Msg.params,9)	---玩法ID
		table.insert(Msg.params,maxPeople)	---最大座位
		table.insert(Msg.params,2)	---支付方式
		table.insert(Msg.params,minidairu)	---最小带入
		table.insert(Msg.params,choushui)	---抽水 0-5
		
		
		
		table.insert(Msg.strParams,tostring(groupkey))	---游戏ID
		table.insert(Msg.strParams,roomname)	---房间名字
		
		NetMgr:SendMsg(1002, Msg)
	end

	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(9,0,callback)
end

--------兑换码
function ClubModule.CDKeyCm(cdkey)
	local Msg = require("Protol.commonMessage_pb").CDKeyCm()
	Msg.cdkey = cdkey
	Debug.LogErrorEx("兑换码----------------"..stringify(Msg.cdkey))
	NetMgr:SendMsg(2102, Msg)
end

function ClubModule.CDKeySm(CDKeySm)
	Debug.LogErrorEx("------------收到兑换码消息--------------"..stringify(CDKeySm))
	
	local MainUserData = require("DynamicData.MainUserData").MainUserData
   	MainUserData.diamond = CDKeySm.cards

   	local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
   	NewGameLoobyWin.zuanshilable.text = MainUserData.diamond
end

function ClubModule.updateNewMsg(newMsgSm)
	local SoundModule = require("Module.SoundModule").SoundModule
	if newMsgSm.type == 1 then --申请邀请
		SoundModule:PlaySound("xiaoxi")
	else -- 获得金币
		SoundModule:PlaySound("xx_shoujinbi")
	end

end

---------表情
function ClubModule.ChatCm(formSeat,intContent)
	local Msg = require("Protol.commonMessage_pb").CDKeyCm()
	Msg.formSeat = formSeat
	Msg.toSeat = formSeat
	Msg.intContent = intContent
	Debug.LogErrorEx("发送表情----------------"..intContent)
	NetMgr:SendMsg(2104, Msg)
end

---请求人物信息
function ClubModule.PlayerInfoCm(userID)
	Debug.log("------------请求人物消息--------------"..userID)
	local Msg = require("Protol.commonMessage_pb").PlayerInfoCm()
	Msg.uid = tonumber(userID)
	NetMgr:SendMsg(2105, Msg)
end

---人物信息
function ClubModule.PlayerInfoSm(PlayerInfoSm)
	local NNPlayerInfoWin = UIWinMgr:GetWindow("NNPlayerInfoWin")
	if NNPlayerInfoWin then
		NNPlayerInfoWin:ShowDetailsOfPlayer(PlayerInfoSm)
	end
end

---跑马灯
function ClubModule.MarqueeAction(MarqueeAction)

	local NewPaoMaDengWin = UIWinMgr:OpenWindow("NewPaoMaDengWin")
	if NewPaoMaDengWin then
		NewPaoMaDengWin:SetInfo(MarqueeAction)
	end
end

function ClubModule.ChatSm(ChatSm)
	if ChatSm.type == 4 then
		local JBCModule = require("Module.JBCModule").JBCModule
    	local GameHost = JBCModule.GameHost
		if GameHost ~= nil and GameHost.myIndex ~= tonumber(ChatSm.formSeat) then
			local GmsgModule = require("Module.GmsgModule").GmsgModule
			GmsgModule:RecNewMsg(ChatSm.strContent, tonumber(ChatSm.formSeat))
		end
	else
		-- local GameHost = require("Module.GameModule.NewNNGameHost").NewNNGameHost
		local JBCModule = require("Module.JBCModule").JBCModule
		local sendPlayer = JBCModule.GameHost:GetPlayer(tonumber(ChatSm.formSeat))
		--Debug.LogErrorEx("------------收到表情1111111111消息--------------"..stringify(JBCModule.GameHost.players))
		--Debug.LogErrorEx("------------收到表情2222222222222消息--------------"..stringify(sendPlayer))
	   if sendPlayer ~= nil then
		   -- sendPlayer:WordChat(ChatCast)
		   --Debug.LogErrorEx("------------收到表情消息--------------"..stringify(ChatSm))
		   sendPlayer:NewWordChat(ChatSm)
		   
	   end
	end
	
end

-------修改密码
function ClubModule.UpPassWordCm(pw,npw)
	local Msg = require("Protol.commonMessage_pb").UpdateUserCm()
	Msg.pw = pw
	Msg.npw = npw
	Debug.LogErrorEx("修改密码---------------")
	NetMgr:SendMsg(2103, Msg)
end

-------修改头像
function ClubModule.UpHeadCm(image)
	local Msg = require("Protol.commonMessage_pb").UpdateUserCm()
	Msg.headimg = image
	NetMgr:SendMsg(2103, Msg)
end

------修改名字
function ClubModule.UpdateUserName(userName)
	local Msg = require("Protol.commonMessage_pb").UpdateUserCm()
	Msg.username = userName
	NetMgr:SendMsg(2103, Msg)
end

function ClubModule.UpdateUserSm(UpPassWordSm)
	Debug.LogErrorEx("------------收到修改密码消息--------------"..stringify(UpPassWordSm))
	if UpPassWordSm.code == 0 then
		if UpPassWordSm.type == 1 then
			local str = UIWinMgr:GetIntTextByCode(29)
			UIWinMgr:OpenNewGameNotice(str)
		elseif UpPassWordSm.type == 3 then
			Debug.log("-------------------xiugaimingzi----"..UpPassWordSm.username)
			local MainUserData = require("DynamicData.MainUserData").MainUserData
			MainUserData:UpdateUserName(UpPassWordSm.username)
			local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
			NewGameLoobyWin:UpdateUsername()
		end
	else
		if UpPassWordSm.type == 1 then

			local str = UIWinMgr:GetIntTextByCode(30)
			UIWinMgr:OpenNewGameNotice(str)
		end
	end

end


local getServerDel
-------加入房间之前发送切服消息
function ClubModule.GetServerCm(playType,roomid,getServerDel)
	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.getServerDel = getServerDel
	local Msg = require("Protol.commonMessage_pb").GetServerCm()
	Msg.playType = playType
	Msg.tableId = roomid
	Debug.LogErrorEx("发送切服----------------"..stringify(Msg.params))
	
	NetMgr:SendMsg(2101, Msg)
end

function ClubModule.GetServerSm(GetServerSm)
	-- GetServerSm.serverId
	-- GetServerSm.ip
	-- GetServerSm.port
	local lastIp = UnityEngine.PlayerPrefs.GetString("lastIp")
	local lastPort = UnityEngine.PlayerPrefs.GetString("lastPort")

	local isswlogin = false
	Debug.LogErrorEx(GetServerSm.ip.."收到切服回包lastIp--------------------------"..stringify(GetServerSm))
	if tostring(GetServerSm.ip) == tostring(lastIp) and tostring(GetServerSm.port) == tostring(lastPort) then
		isswlogin = false
	else
		isswlogin = true
	end

	if isswlogin then
		local ClubModule = require("Module.ClubModule").ClubModule
		--需要切服务后创建房间
		if GetServerSm.tableId == 0 then 
			local GameScene = require("Scene.GameScene").GameScene
			GameScene.swServerCrRoom = true
		else
			local GameScene = require("Scene.GameScene").GameScene
			GameScene.swServerJoinRoom = true

			--加入房间需要重挂回调,切服成功后调用
			function callback()
				ClubModule.JoinRoomDel(GetServerSm.tableId, GetServerSm.type)
			end
			ClubModule.getServerDel = callback
		end 

    	Debug.LogErrorEx("需要切服，-------------------------")
    	local NetMgr = require("NetWork").NetMgr
		NetMgr:CloseConnection()
    	local LoginModule = require("Module.LoginModule").LoginModule
		LoginModule:NewSwLogin(GetServerSm.ip,GetServerSm.port, ClubModule.getServerDel)
    	
    else
    	local ClubModule = require("Module.ClubModule").ClubModule
		ClubModule.getServerDel(GetServerSm.tableId, GetServerSm.type)
    end
end

function ClubModule.JoinRoomOperation(tableId)
	local str = UIWinMgr:GetIntTextByCode(31)
	UIWinMgr:OpenMask(str)
	local ClubModule = require("Module.ClubModule").ClubModule
	ClubModule.GetServerCm(0,tableId,ClubModule.JoinRoomDel)
end


function ClubModule.JoinRoomDel(tableId, roomType)
   print("进入房间-------------------------"..roomType)
    local ClubModule = require("Module.ClubModule").ClubModule
    -- Event.Brocast(EventDefine.OnChangeSever)
    if tableId > 0 then
        if roomType == 1 then
            Debug.LogErrorEx("断线重连加载新版NN模块----------------")
            local NewNNBootModule = require("Module.NewNNBootModule").NewNNBootModule
            NewNNBootModule:Init()
        elseif roomType == 2 then
            Debug.LogErrorEx("断线重连加载新版闲家NN模块----------------")
            local NewTZNNBootModule = require("Module.NewTZNNBootModule").NewTZNNBootModule
            NewTZNNBootModule:Init()
        elseif roomType == 3 then
            Debug.LogErrorEx("断线重连加载新版盲压NN模块----------------")
            local NewMYNNBootModule = require("Module.NewMYNNBootModule").NewMYNNBootModule
            NewMYNNBootModule:Init()
        elseif roomType == 4 then
            Debug.LogErrorEx("断线重连加载新版推筒子模块----------------")
            local TTZBootModule = require("Module.TTZBootModule").TTZBootModule
            TTZBootModule:Init()
        elseif roomType == 5 then
            -- Debug.LogErrorEx("断线重连加载高倍牛牛模块----------------")
            -- local GBNNBootModule = require("Module.GBNNBootModule").GBNNBootModule
            -- GBNNBootModule:Init()
        elseif roomType == 6 then
            Debug.LogErrorEx("断线重连加载炸金花模块----------------")
            local ZJHBootModule = require("Module.ZJHBootModule").ZJHBootModule
            ZJHBootModule:Init()
        elseif roomType == 7 then
            Debug.LogErrorEx("断线重连加载三公模块----------------")
            local NewSanGongBootModule = require("Module.NewSanGongBootModule").NewSanGongBootModule
            NewSanGongBootModule:Init()
        elseif roomType == 8 then
            Debug.LogErrorEx("断线重连加载高倍牛牛模块----------------")
            local GBNNBootModule = require("Module.GBNNBootModule").GBNNBootModule
            GBNNBootModule:Init()
        elseif roomType == 9 then
            Debug.LogErrorEx("断线重连加载德州模块----------------")
            local DeZhouBootModule = require("Module.DeZhouBootModule").DeZhouBootModule
            DeZhouBootModule:Init()
        elseif roomType == 101 then
            Debug.LogErrorEx("断线重连到SB")
            
            local SBBootModule = require("Module.SBBootModule").SBBootModule
		  local	SAIBAOGameWin=	UIWinMgr:OpenWindow("SAIBAOGameWin")
			SAIBAOGameWin.tableId = tableId
            SAIBAOGameWin.groupkey = ClubModule.groupkey
            SBBootModule:Init()
          
            if not SAIBAOGameWin.isInit then
                return
            end
        end


        ClubModule.JoinRoomCm(tableId, ClubModule.groupKey)
    end
end


-------加入房间通用消息
function ClubModule.JoinRoomCm(roomid,groupkey)
	local Msg = require("Protol.comMessage_pb").ComReq()
	Msg.code=2
	-- Debug.LogErrorEx(groupkey.."发送加入房间---11111111111-------------"..stringify(Msg.params))
	Debug.log(roomid.."发送加入房间----------------"..stringify(Msg.params))
	table.insert(Msg.params,roomid)	---游戏总时间
	if groupkey ~= nil then
		Debug.LogErrorEx(groupkey.."发送加入房间---11111111111-------------")
		table.insert(Msg.params,groupkey)
	end
	
	NetMgr:SendMsg(1002, Msg)
end

-------查看俱乐部详情
function ClubModule.LoadGroupInfoCm(keyId)
	--Debug.LogErrorEx("groupkey---------------"..keyId)
	local Msg = require("Protol.groupMessage_pb").LoadGroupInfoCm()
	if keyId == nil then
		Msg.keyId = 0
	else
		Msg.keyId = tonumber(keyId) 
	end
	NetMgr:SendMsg(2013, Msg)
end

function ClubModule.LoadGroupInfoSm(LoadGroupInfoSm)
	Debug.LogErrorEx("------------收到LoadGroupInfoSm消息--------------"..stringify(LoadGroupInfoSm))
	-- local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
	-- NewGameLoobyWin:SetClubDetailsInfo(LoadGroupInfoSm)
	local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
	NewClubDetailsWin:SetClubDetailsInfo(LoadGroupInfoSm)
	--NewClubDetailsWin:BringToTop()
	
end


----新游戏购买金币

function ClubModule.BuyGoldCm(groupKey,serial)
	--Debug.LogErrorEx(groupKey.."购买金币发包---------------"..serial)
	if groupKey ~= nil then 
		local Msg = require("Protol.groupMessage_pb").BuyGoldCm()
		Msg.groupKey = tonumber(groupKey) 
		Msg.serial = tonumber(serial)
		NetMgr:SendMsg(2018, Msg)
	end
end

function ClubModule.BuyGoldSm(BuyGoldSm)
	Debug.LogErrorEx("收到购买金币回包---------------"..stringify(BuyGoldSm))
	if BuyGoldSm.code == 0 then
		--local ClubModule = require("Module.ClubModule").ClubModule
  		--ClubModule.LoadGroupInfoCm(BuyGoldSm.groupKey)
		local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
		NewClubDetailsWin:UpdateMyCoin(BuyGoldSm.gold)
  	 	--ClubModule.LoadGroupCm()
		   local str = UIWinMgr:GetIntTextByCode(32)
		   UIWinMgr:OpenNewGameNotice(str)
	else
		local str = UIWinMgr:GetIntTextByCode(74)
		UIWinMgr:OpenNewGameNotice(str)
	end
end

---查看积分流动记录
function ClubModule.CheckJfCm()
	local Msg = require("Protol.groupMessage_pb").LoadGoldRecordStatisticsCm()
	NetMgr:SendMsg(2027, Msg)
end

function ClubModule.CheckJfSm(CheckJfSm)
	local NewCheckJfWin = UIWinMgr:OpenWindow("NewCheckJfWin")
	if NewCheckJfWin then
		NewCheckJfWin:BringToTop()
		NewCheckJfWin:ShowInfo(CheckJfSm)
	end
end

---新游戏退出俱乐部
function ClubModule.ExitGroupCm(id)
	Debug.LogErrorEx("退出俱乐部发包---------------")
	local Msg = require("Protol.groupMessage_pb").ExitGroupCm()
	Msg.id = tonumber(id)
	NetMgr:SendMsg(2004, Msg)
end

function ClubModule.ExitGroupSm(ExitGroupSm)
	Debug.LogErrorEx("收到退出俱乐部回包---------------"..stringify(ExitGroupSm))
	-- UIWinMgr:OpenNotice(ExitAllianceSm.msg)
	if ExitGroupSm.code == 0 then
		local str = UIWinMgr:GetIntTextByCode(33)
		UIWinMgr:OpenNewGameNotice(str)
		--UIWinMgr:CloseWindow("NewGamemyjulebuWin")
		-- local ClubModule = require("Module.ClubModule").ClubModule
		--ClubModule.LoadGroupInfoCm(ExitGroupSm.id)
		ClubModule.LoadGroupCm(0)
		UIWinMgr:CloseWindow("NewClubDetailsWin")
		UIWinMgr:CloseWindow("NewClubTablesWin")
		-- local ClubModule = require("Module.ClubModule").ClubModule
  	 	-- ClubModule.LoadGroupCm()
	else
		-- UIWinMgr:OpenNotice("退出俱乐部成功")
	end
end

---新游戏退出联盟
function ClubModule.ExitAllianceCm(allianceKey,groupKey)
	Debug.LogErrorEx("退出联盟发包---------------")
	local Msg = require("Protol.groupMessage_pb").ExitAllianceCm()
	Msg.allianceKey = tonumber(allianceKey)
	Msg.groupKey = tonumber(groupKey)
	NetMgr:SendMsg(2022, Msg)
end

function ClubModule.ExitAllianceSm(ExitAllianceSm)
	Debug.LogErrorEx("收到退出联盟回包---------------"..stringify(ExitAllianceSm))
	-- UIWinMgr:OpenNotice(ExitAllianceSm.msg)
	if ExitAllianceSm.code == 0 then
		local str = UIWinMgr:GetIntTextByCode(75)----
		UIWinMgr:OpenNewGameNotice(str)
		--UIWinMgr:OpenNotice("退出联盟成功")
		
		local NewGameLianMengWin = UIWinMgr:GetWindow("NewGameLianMengWin") 
		NewGameLianMengWin:ResetInfo()
		NewGameLianMengWin:Close()

		local ClubModule = require("Module.ClubModule").ClubModule
  		ClubModule.LoadGroupInfoCm(ExitAllianceSm.groupkey)
	end
end
---新游戏踢出联盟
function ClubModule.FireAllianceCm(allianceKey,groupKey)
	Debug.LogErrorEx("踢出联盟发包---------------")
	local Msg = require("Protol.groupMessage_pb").FireAllianceCm()
	Msg.allianceKey = tonumber(allianceKey)
	Msg.groupKey = tonumber(groupKey)
	NetMgr:SendMsg(2023, Msg)
end

function ClubModule.FireAllianceSm(FireAllianceSm)
	Debug.LogErrorEx("收到踢出联盟回包---------------"..stringify(FireAllianceSm))
	-- UIWinMgr:OpenNotice(ExitAllianceSm.msg)
	if FireAllianceSm.code == 0 then
		local str = UIWinMgr:GetIntTextByCode(34)
		UIWinMgr:OpenNewGameNotice(str)
		local ClubModule = require("Module.ClubModule").ClubModule
  	 	ClubModule.LoadAllianceGroupCm(FireAllianceSm.groupKey)
	end
end

----新游戏修改俱乐部
function ClubModule.UpdateGroupCm(groupKey,amountLimit,ps,fixType,notice,clubHead)
	Debug.LogErrorEx(groupKey.."修改限额发包---------------")
	local Msg = require("Protol.groupMessage_pb").UpdateGroupCm()
	Msg.groupKey = tonumber(groupKey) 
	if amountLimit then
		Msg.amountLimit = amountLimit
	end
	Msg.ps = "111111"
	if fixType then
		Msg.type = fixType
	end
	if notice then
		Msg.gMsg = notice
	end
	if clubHead then 
		Msg.img = clubHead
	end
	NetMgr:SendMsg(2019, Msg)
end

function ClubModule.UpdateGroupSm(UpdateGroupSm)
	Debug.LogErrorEx("收到修改限额回包---------------"..stringify(UpdateGroupSm))
	UIWinMgr:OpenNotice(UpdateGroupSm.msg)
	if UpdateGroupSm.type == 1 then
		local NewClubDetailsWin = UIWinMgr:GetWindow("NewClubDetailsWin")
		UIWinMgr:CloseWindow("NewSetClubNoticeWin")
		NewClubDetailsWin:UpdateNotice(UpdateGroupSm.group.descMsg)
	elseif UpdateGroupSm.type == 0 then 
		local NewGameLianMengWin = UIWinMgr:GetWindow("NewGameLianMengWin")

		local ClubModule = require("Module.ClubModule").ClubModule
		  ClubModule.LoadAllianceGroupCm(NewGameLianMengWin.clubinfo.keyId)
	elseif UpdateGroupSm.type ==3 then
		UIWinMgr:CloseWindow("NewClubDetailsWin")
		UIWinMgr:CloseWindow("NewClubTablesWin")
		local ClubModule = require("Module.ClubModule").ClubModule
		ClubModule.LoadGroupCm(0) 
	end

end

----抽奖
----请求抽奖列表
function ClubModule.LoadChouJiangReqCm(groupKey)--俱乐部Key 从选择俱乐部进入需要传
	local Msg = require("Protol.activityMessage_pb").LoadChouJiangReq()
	if groupKey then
		Msg.groupKey = tonumber(groupKey)
	end
	NetMgr:SendMsg(2201, Msg)
end

--抽奖列表返回
function ClubModule.LoadChouJiangResSm(LoadChouJiangRes)--groupKey 1俱乐部Key gameCredits 2自己游戏积分 goodsList (GoodsBn)3商品列表 condition 4抽奖条件 maxPrizeNum 5最大奖品数
	-- UIWinMgr:OpenNotice(LoadChouJiangRes.msg)
	local NewNNChouJiangWin =  UIWinMgr:OpenWindow("NewNNChouJiangWin")
	NewNNChouJiangWin:SetInfo(LoadChouJiangRes)
end

----请求抽奖
function ClubModule.ChouJiangReqCm(groupKey)--没带入的需要传入俱乐部key
	local Msg = require("Protol.activityMessage_pb").ChouJiangReq()
	if groupKey then
		Msg.groupKey = tonumber(groupKey)
	end
	NetMgr:SendMsg(2202, Msg)
end

--抽奖返回
function ClubModule.ChouJiangResSm(ChouJiangRes)--ordinal 1商品序号 gameCredits 2自己游戏积分
	-- UIWinMgr:OpenNotice(ChouJiangRes.msg)
	local NewNNChouJiangWin =  UIWinMgr:OpenWindow("NewNNChouJiangWin")
	NewNNChouJiangWin:ChoujiangItemAni(ChouJiangRes)
end

--玩家可选俱乐部返回
function ClubModule.GroupUserResSm(GroupUserRes)--groupUsers (GroupUserBn) 所有俱乐部
	local NewGameCJXZWin =  UIWinMgr:OpenWindow("NewGameCJXZWin")
	NewGameCJXZWin:SetClubsInfo(GroupUserRes)
end

----强制踢人下桌
function ClubModule.FirePlayerCm(userID)
	local Msg = require("Protol.commonMessage_pb").FirePlayerCm()
	Msg.userId = userID
	NetMgr:SendMsg(2107, Msg)
end

---查看战绩请求
function ClubModule.GameStatsCm(dateVal) ---0当前1三天2七天   2108   hui  2109
	local Msg = require("Protol.commonMessage_pb").GameStatsCm()
	Msg.dateVal  = dateVal
	NetMgr:SendMsg(2108, Msg)
end
---查看战绩返回
function ClubModule.GameStatsSm(GameStatsSm) ---0当前1三天2七天   
	local NewCountWin =  UIWinMgr:GetWindow("NewCountWin")
	NewCountWin:BringToTop()
	NewCountWin:ShowRecordInfo(GameStatsSm)
end

--支付请求
function ClubModule.GetPayCm(payVal)
	local Msg = require("Protol.commonMessage_pb").GetPayCm()
	Msg.payVal  = payVal
	NetMgr:SendMsg(2109, Msg)
end
--支付返回
function ClubModule.GetPaySm (GetPaySm) 
	local str = UIWinMgr:GetIntTextByCode(105)
	UIWinMgr:CloseMask()
	if GetPaySm.location == "" or  GetPaySm.location == nil then
		UIWinMgr:OpenNotice(str)
	else
		local WebViewWindow =  UIWinMgr:OpenWindow("WebViewWindow")
		WebViewWindow:SetUrl(GetPaySm.location)
		--WebViewWindow:SetUrl("http://www.baidu.com")
		--UnityEngine.Application.OpenURL(GetPaySm.location)
	end
end

----充值成功返回
function ClubModule.PaySm(PaySm)
	if PaySm.status == 0 then
		local str = UIWinMgr:GetIntTextByCode(105)
		UIWinMgr:OpenNotice(str)
	else
		UIWinMgr:CloseWindow("WebViewWindow")
		local MainUserData = require("DynamicData.MainUserData").MainUserData
		MainUserData.currentclubgold = PaySm.gold
		local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
		NewGameLoobyWin:UpdateUserInfo()
		local str1 = UIWinMgr:GetIntTextByCode(106)
		UIWinMgr:OpenNotice(str1.." : "..PaySm.payGold)
	end
end

---请求大厅桌子信息
function ClubModule.LobbyGameCm()
	local Msg = require("Protol.commonMessage_pb").LobbyGameCm()
	NetMgr:SendMsg(2111, Msg)
end

function ClubModule.LobbyGameSm(LobbyGameSm)
	if LobbyGameSm then
		local NewGameLoobyWin = UIWinMgr:GetWindow("NewGameLoobyWin")
		NewGameLoobyWin:SetAllGamesInfo(LobbyGameSm)
	end
end


---请求下分
function ClubModule.DownFenCm(name,bank,cardNo,gold)
	local Msg = require("Protol.commonMessage_pb").DownFenCm()
	Msg.name = name
	Msg.bank = bank
	Msg.cardNo = cardNo
	Msg.gold = gold
	NetMgr:SendMsg(2110, Msg)
end

----下分成功  
function ClubModule.DownFenSm(DownFenSm)

end

---钻石转积分
function ClubModule.ChangeGoldCm(gold)
	local Msg = require("Protol.commonMessage_pb").ChangeGoldCm()
	Msg.fen = gold
	NetMgr:SendMsg(2112, Msg)
end